package com.restaurant.application.indexes.customerlist;

import com.nebutown.description.DataTypes;
import com.nebutown.description.IndexGen;
import com.nebutown.description.UnitDescription;
import com.nebutown.description.data.Contributor;
import com.nebutown.description.data.IndexUnit;
import com.nebutown.description.data.SQLColumn;
import com.restaurant.application.customer.Customer;
import com.restaurant.application.indexes.customerlist.mysql.CustomerListCriteria;

/**
 * @author Administrator
 */
public class AssistCustomerListDesc extends UnitDescription {

    public static void main(String[] args) {
        getUnitDescription().run("./");
        IndexGen.run(getDescription(), "src/main/java");
    }

    private static UnitDescription getUnitDescription() {
        UnitDescription desc = UnitDescription.basicUnit(AssistCustomerList.class, null);

        desc.nextBean("CustomerIdData").add("id", String.class);

        desc.addUiFunction("search", CustomerListCriteria.class.getName());
        desc.addUiFunction("modify", null);
        return desc;
    }

    public static IndexUnit getDescription() {
        return new IndexUnit()
                .withName("CustomerList")
                .withPackageName(AssistCustomerListDesc.class.getPackage().getName() + ".mysql")
                .withSrcLocation("./")
                .addContributors(new Contributor()
                        .withName("customerUid")
                        .withNullable(false)
                        .withUnique(true)
                        .withUnitType(Customer.class.getName())
                        .addContribution(getSQLColumn("id", DataTypes.STRING, "用户id", 255))
                        .addContribution(getSQLColumn("createTime", DataTypes.LONG, "创建时间", 20))
                        .addContribution(getSQLColumn("modifyTime", DataTypes.LONG, "修改时间", 20))
                        .addContribution(getSQLColumn("avatarUrl", DataTypes.STRING, "头像地址", 255))
                        .addContribution(getSQLColumn("nickName", DataTypes.STRING, "登陆名称", 255))
                        .addContribution(getSQLColumn("realName", DataTypes.STRING, "登陆名称", 255))
                        .addContribution(getSQLColumn("gender", DataTypes.STRING, "性别", 255))
                        .addContribution(getSQLColumn("birthday", DataTypes.STRING, "生日", 255))
                        .addContribution(getSQLColumn("openId", DataTypes.STRING, "openId", 255))
                        .addContribution(getSQLColumn("phone", DataTypes.STRING, "手机", 255))
                        .addContribution(getSQLColumn("levelName", DataTypes.STRING, "会员等级名称", 255))
                        .addContribution(getSQLColumn("level", DataTypes.STRING, "会员等级", 255))
                        .addContribution(getSQLColumn("number", DataTypes.STRING, "会员编号", 255))
                        .addContribution(getSQLColumn("qrCodeUrl", DataTypes.STRING, "会员二维码地址", 255))
                        .addContribution(getSQLColumn("qrCodeUid", DataTypes.STRING, "会员二维码Uid", 255))
                        .addContribution(getSQLColumn("usableScores", DataTypes.STRING, "可用积分", 255))
                        .addContribution(getSQLColumn("totalScores", DataTypes.STRING, "总积分", 255))
                        .addContribution(getSQLColumn("state", DataTypes.STRING, "状态", 255))
                        .addContribution(getSQLColumn("address", DataTypes.STRING, "状态", 255))
                );
    }

    private static SQLColumn getSQLColumn(String name, DataTypes type, String label, Integer width) {
        return new SQLColumn().withName(name).withType(type).withLabel(label).withWidth(width);
    }
}
